#include <iostream>
#include <vector>
#include <string>

using namespace std;

int repeatedStringMatch(string a, string b) {
    for(int n = 0; n < a.size(); n++){
        int times = 1, i = n, j = 0;
        while(a[i] == b[j]){
            if(++j == b.size()) return times;
            if(++i == a.size()){
                times++;
                i = i % a.size();
            }
        }
    }
    return -1;
}

int main(){
    // string a = "abcd", b = "cdabcdab";
    // string a = "aabaa", b = "aaab";
    string a = "a", b = "aa";
    cout << repeatedStringMatch(a, b) << endl;
    return 0;
}
